/*!
 @header UIAlertController+JPBlocks.h
 @abstract UIAlertController分类
 @author BruceHu
 @version 1.00 2020/08/31 Creation
 */

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

#if TARGET_OS_IOS
/**
 弹窗视图pop block
 @param popover 弹窗视图pop后的视图
 */
typedef void (^UIAlertControllerPopoverPresentationControllerBlock) (UIPopoverPresentationController * __nonnull popover);
#endif
/**
 弹窗点击block
 @param controller 弹窗
 @param action 弹窗点击事件
 @param buttonIndex 弹窗点击按钮
 */
typedef void (^UIAlertControllerCompletionBlock) (UIAlertController * __nonnull controller,
                                                  UIAlertAction * __nonnull action,
                                                  NSInteger buttonIndex);

@interface UIAlertController (JPBlocks)
/*!
 @method
 @abstract show弹窗
 @discussion show弹窗
 @param viewController 弹窗视图
 @param title 弹窗标题
 @param message 弹窗内容
 @param preferredStyle 弹窗类型
 @param cancelButtonTitle 弹窗取消按钮文案
 @param destructiveButtonTitle 弹窗确定按钮文案
 @param otherButtonTitles 弹窗其他按钮文案数组
 @param popoverPresentationControllerBlock 弹窗视图点击popover交互的回调（TARGET_OS_IOS）
 @param tapBlock 弹框按钮点击回调
 @return 返回创建好的弹窗
 */
+ (nonnull instancetype)showInViewController:(nonnull UIViewController *)viewController
                                   withTitle:(nullable NSString *)title
                                     message:(nullable NSString *)message
                              preferredStyle:(UIAlertControllerStyle)preferredStyle
                           cancelButtonTitle:(nullable NSString *)cancelButtonTitle
                      destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle
                           otherButtonTitles:(nullable NSArray *)otherButtonTitles
#if TARGET_OS_IOS
          popoverPresentationControllerBlock:(nullable UIAlertControllerPopoverPresentationControllerBlock)popoverPresentationControllerBlock
#endif
                                    tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock;

/*!
 @method
 @abstract show弹窗
 @discussion show弹窗
 @param viewController 弹窗视图
 @param title 弹窗标题
 @param message 弹窗内容
 @param cancelButtonTitle 弹窗取消按钮文案
 @param destructiveButtonTitle 弹窗确定按钮文案
 @param otherButtonTitles 弹窗其他按钮文案数组
 @param tapBlock 弹窗按钮点击回调
 @return 返回创建好的弹窗
 */
+ (nonnull instancetype)showAlertInViewController:(nonnull UIViewController *)viewController
                                        withTitle:(nullable NSString *)title
                                          message:(nullable NSString *)message
                                cancelButtonTitle:(nullable NSString *)cancelButtonTitle
                           destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle
                                otherButtonTitles:(nullable NSArray *)otherButtonTitles
                                         tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock;


/*!
 @method
 @abstract show操作表
 @discussion show操作表
 @param viewController 操作表视图
 @param title 操作表标题
 @param message 操作表内容
 @param cancelButtonTitle 操作表取消按钮文案
 @param destructiveButtonTitle 操作表确定按钮文案
 @param otherButtonTitles 操作表其他按钮文案数组
 @param popoverPresentationControllerBlock 操作表视图点击popover交互的回调（TARGET_OS_IOS）
 @param tapBlock 操作表按钮点击回调
 @return 返回创建好的操作表
 */
+ (nonnull instancetype)showActionSheetInViewController:(nonnull UIViewController *)viewController
                                              withTitle:(nullable NSString *)title
                                                message:(nullable NSString *)message
                                      cancelButtonTitle:(nullable NSString *)cancelButtonTitle
                                 destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle
                                      otherButtonTitles:(nullable NSArray *)otherButtonTitles
#if TARGET_OS_IOS
                     popoverPresentationControllerBlock:(nullable UIAlertControllerPopoverPresentationControllerBlock)popoverPresentationControllerBlock
#endif
                                               tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock;


/*!
 @property
 @abstract 是否可见
 */
@property (readonly, nonatomic) BOOL visible;

/*!
 @property
 @abstract 取消按钮index
 */
@property (readonly, nonatomic) NSInteger cancelButtonIndex;

/*!
 @property
 @abstract 确定按钮index
 */
@property (readonly, nonatomic) NSInteger destructiveButtonIndex;

/*!
 @property
 @abstract 第一个其他按钮的index
 */
@property (readonly, nonatomic) NSInteger firstOtherButtonIndex;
@end

NS_ASSUME_NONNULL_END
